\documentclass[a4paper]{article}
\usepackage{geometry}
\usepackage{listings}
\usepackage{graphicx}
\usepackage{float}
\usepackage{bm}
\title{HOMEWORK03-PROGRAMMING}
\author{3190101820 Weizhen Li}
\date{2021-11-27}
\geometry{left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm}
\lstset{numbers=left,basicstyle=\footnotesize,showstringspaces=false,otherkeywords={string},language = C++}
\begin{document}
\maketitle
\paragraph{Programming B}
The maxnorm of the interpolation error vector at the mid-points of subintervals are as follows:
\begin{table}[htbp]
\centering
\setlength{\tabcolsep}{3mm}{
\begin{tabular}{|c|c|c|c|c|c|c|} 
\hline
Type &N=6 & N=11 & N=21 & N=41 & N=81 & convergence rate\\ 
\hline
complete  & 0.421705 & 0.0205289& 0.00316894& 0.000275356&1.609e-05&\\
\hline
not a knot & 0.431538 & 0.0205334 & 0.00316894&0.000275356 &1.609e-05&\\
\hline
\end{tabular}}
\end{table}

\begin{figure}[H]
	\centering
\includegraphics[width=13cm]{B-1.png}
\caption{N=6}
\end{figure} 
\begin{figure}[H]
	\centering
	\includegraphics[width=13cm]{B-2.png}
	\caption{N=11}
\end{figure} 
\begin{figure}[H]
	\centering
	\includegraphics[width=13cm]{B-3.png}
	\caption{N=21}
\end{figure} 
\begin{figure}[H]
	\centering
	\includegraphics[width=13cm]{B-4.png}
	\caption{N=41}
\end{figure} 
\begin{figure}[H]
	\centering
	\includegraphics[width=13cm]{B-5.png}
	\caption{N=81}
\end{figure} 

\paragraph{Programming C} 
Just use cubic and quadratic cardinal B-spline.
\begin{figure}[H]
	\centering
	\includegraphics[width=13cm]{C.png}
\end{figure} 


\paragraph{Programming D}
$E_{S}(x)$ at these sites are as follows:
\begin{table}[htbp]
	\centering
	\setlength{\tabcolsep}{1mm}{
		\begin{tabular}{|c|c|c|c|c|c|c|c|} 
			\hline
			Type &x=-3.5 & x=-3 & x=-0.5 & x=0 & x=0.5 & x=3& x=3.5 \\ 
			\hline
			cubic B-spline  & 0.000669568 &9.15934e-16 &0.0205289 & 1.11022e-16&0.0205289 &1.30451e-15&0.000669568 \\
			\hline
			quadratic B-spline & 1.249e-16 & 0.00141838 & 0 & 0.120238& 0 & 0.00141838 &1.249e-16\\
			\hline
		\end{tabular}}
\end{table}

Some of the errors close to machine precision,because in which the sites are the interpolation sites of corresponding spline,that is,at these sites,the interpolation values 
are very close to its real values,almost the same.According to the nature of machine operation,at these sites,the $E_{S}(x)$ is close to machine precision.\\ 
In addition,obviously,cubic cardinal B-spline is more accurate!\\

\paragraph{Programming E}
Since $\frac{dy}{dx}$ at $x=0$ is $\infty$,we use not-a-knot cubic spline.In addition,we interpolate only half and draw the other half by symmetry.
\begin{figure}[H]
	\centering
	\includegraphics[width=13cm]{E-1.png}
	\caption{n=10}
\end{figure} 

\begin{figure}[H]
	\centering
	\includegraphics[width=13cm]{E-2.png}
	\caption{n=40}
\end{figure} 
\begin{figure}[H]
	\centering
	\includegraphics[width=13cm]{E-3.png}
	\caption{n=160}
\end{figure} 

\paragraph{Programming F} Just use complete cubic spline.

\begin{figure}[H]
	\centering
	\includegraphics[width=13cm]{F.png}
\end{figure} 
\end{document}